<?php defined('SYSPATH') or die('No direct script access.');

class Controller_Ajax_Category extends Controller{

public function action_index()
{
}

public function action_add()
{
	$name =  arr::get($_POST, 'name');
	if (!$name)
	{
		echo '类别名为空';
		return;
	}
	// 保存category数据
	$category = ORM::factory('category');
	$category->name = $name;
	try
	{
		$category->save();
	}
	catch (ORM_Validation_Exception $e)
	{
		$errors = $e->errors('model');
		return;
	}
	echo '添加成功';
}

}




